<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .father {
            width: 300px;
            height: 300px;
            background-color: #f00;
        }

        .son {
            width: 100px;
            height: 100px;
            background-color: #0f0;
        }
    </style>
</head>
<body>
    <div id="app">
        <!-- a标签默认就有点击事件的行为：就是进行跳转 -->
        <a @click.prevent="fn1" href="http://www.itcast.cn">点我跳转</a>

        <!-- 阻止冒泡 -->
        <!-- 事件冒泡：指的是一个事件触发后，会依次向上调用所有父级的同名事件 -->
        <div @click="fn2" class="father">

            <!-- 点击事件时并阻止事件冒泡 -->
            <div @click.stop="fn3" class="son"></div>

            <!-- 我既想阻止默认行为，又想阻止冒泡，可以连着写 -->
            <a @click.prevent.stop="fn1" href="http://www.itcast.cn">点我跳转</a>
            <a @click.stop.prevent="fn1" href="http://www.itcast.cn">点我跳转</a>
        </div>
    </div>

    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            methods: {
                fn1 () {
                    alert('a被点了')
                },

                fn2 () {
                    alert('大盒子被点')
                },

                fn3 () {
                    
                    alert('小盒子被点')
                }
            }
        })
    </script>
</body>
</html>